package fab.forms.fields 
{
	import fab.forms.error.FormError;
	/**
	 * ...
	 * @author fab
	 */
	public class Element
	{
		private var _errors:Vector.<FormError>;
		public var name:String;
		
		public function Element() 
		{
			_errors = new Vector.<FormError>();
		}
		
		public function validate():FormError
		{
			/*
			 * traiter toutes les erreurs FormError.STATICS concernant ce type d'élément
			 * */
			return null;
		}
		public function getValue():String
		{
			return null;
		}
		public function hasError(errortype:String):Boolean
		{
			for each( var error:FormError in _errors ) if ( error.type == errortype ) return true;
			return false;
		}
		public function getError(errortype:String):FormError
		{
			for each( var error:FormError in _errors ) if ( error.type == errortype ) return error;
			return null;
		}		
		public function addError(error:FormError):void
		{
			_errors.push( error );
		}
	}

}